//
//  SYKCNotClassCollectionViewCell.m
//  SanYiTeaching
//
//  Created by 三一 on 2020/1/10.
//  Copyright © 2020 SanYi. All rights reserved.
//

#import "SYKCNotClassCollectionViewCell.h"
#import "KeChengYiShangKeShiModel.h"
#import "KeChengWeiShangKeShiModel.h"

@interface SYKCNotClassCollectionViewCell ()
@property (weak, nonatomic) IBOutlet UILabel *titleLab;//标题
@property (weak, nonatomic) IBOutlet UILabel *nameLab;//名字
@property (weak, nonatomic) IBOutlet UILabel *schoolLab;//校区名字
@property (weak, nonatomic) IBOutlet UILabel *timeLab;//时间
@property (weak, nonatomic) IBOutlet UIButton *lookBtn;//申请查看
@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UILabel *chuqinLab;//出勤
@property (assign, nonatomic) NSInteger selectIndex; //0 申请 1 查看 2不做动作

@end



@implementation SYKCNotClassCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.bgView.layer.cornerRadius = 10;
    self.bgView.layer.masksToBounds = YES;
    
    
}
- (void)transferDataKeChengModel:(KeChengYiShangKeShiModel *)ysks
                 keChengWeiModel:(KeChengWeiShangKeShiModel *)wsks
                        cellType:(NSString *)celltype
{
    if ([celltype isEqualToString:@"未上课时"]) {
        self.titleLab.text = [NSString stringWithFormat:@"%@%@",wsks.courseName,wsks.lessonName];
        self.nameLab.text = wsks.teacherName;
        self.schoolLab.text = [NSString stringWithFormat:@"%@%@",wsks.campusName,wsks.classroom];
        self.timeLab.text = [NSString stringWithFormat:@"%@ %@",wsks.campusName,wsks.attendTime];
        
        self.lookBtn.hidden = NO;
        NSMutableString *resource = wsks.isViewResource;
        if ([resource intValue] == 1) {//可以查看
            if ([wsks.applyStatus isEqualToString:@"-1"]) {
                self.chuqinLab.hidden = YES;
            } else {
                self.chuqinLab.hidden = NO;
            }
            self.selectIndex = 1;
            self.chuqinLab.text = wsks.applyStatusName;
            self.chuqinLab.textColor = [UIColor colorWithHexString:@"#FF0000"];
            [self.lookBtn setTitle:@"" forState:UIControlStateNormal];
            [self.lookBtn setImage:[UIImage imageNamed:@"sx_xiaozu_chakan"] forState:UIControlStateNormal];
        } else {//申请
            self.selectIndex = 0;
            NSMutableString *status = wsks.applyStatus;
            if ([status intValue] == 1) {
                self.chuqinLab.hidden = NO;
                self.chuqinLab.text = wsks.applyStatusName;
                if ([wsks.applyStatusName isEqualToString:@"准"]) {
                    self.chuqinLab.textColor = [UIColor colorWithHexString:@"#20B097"];
                } else {
                    self.chuqinLab.textColor = [UIColor colorWithHexString:@"#FF0000"];
                }
                
            } else {
                self.chuqinLab.hidden = YES;
            }
            
            [self.lookBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
            [self.lookBtn setTitle:@"申请" forState:UIControlStateNormal];
        }
        
        
    } else {
        self.selectIndex = 2;
        self.chuqinLab.hidden = NO;
        self.lookBtn.hidden = YES;
        if ([ysks.signStudentNums isEqualToString:@"0"]) {
            self.bgView.backgroundColor = [UIColor colorWithHexString:@"#FFFC9D"];
        }else{
            self.bgView.backgroundColor = CONTENTBACKCOLOR;
        }
        self.titleLab.text = [NSString stringWithFormat:@"%@%@",ysks.courseName,ysks.lessonName];
        self.nameLab.text = ysks.teacherName;
        self.schoolLab.text = [NSString stringWithFormat:@"%@%@",ysks.campusName,ysks.classroom];
        self.timeLab.text = [NSString stringWithFormat:@"%@ %@",ysks.campusName,ysks.attendTime];
        NSString *str = [NSString stringWithFormat:@"出勤 %@/%@",ysks.signStudentNums,ysks.studentNums];
        self.chuqinLab.attributedText = [PublickFunctionObject getPriceAttribute:str and:[UIColor redColor] andChangeBenginString:@" " andEndString:@"/" andSize:12];
        
    }
}
//申请查看
- (IBAction)lookBtnClick:(UIButton *)sender {
    if (self.block) {
        self.block(self.selectIndex);
    }
}



@end
